package sim;

public class Random
{
	/**
	 * @param max
	 *            Maximum value that is to be returned
	 * @return a random value between 1 and max
	 */
	public static int randomCap(int max)
	{
		int scale = (int) Math.pow(10, (max - 1 + "").length());
		int num = (int) (Math.random() * scale);
		while (num > max - 1)
		{
			num = (int) (Math.random() * scale);
		}
		return num + 1;
	}

	/**
	 * 
	 * @param max
	 *            Maximum value that is to be returned
	 * @param size
	 *            Number of values to be returned in array
	 * @return an array of random values between 1 and max
	 */
	public static int[] randomCapArray(int max, int size)
	{
		int[] ret = new int[size];

		for (int i = 0; i < size; i++)
			ret[i] = randomCap(max);

		return ret;
	}
}
